import React from 'react'
import routes from './routes'
import { BrowserRouter, Routes, Route } from 'react-router-dom'
type Props = {}

const routerView = (routes: any) => {
	return (
		<>
			{
				routes.map((v: any, i: number) => {
					return <Route key={i} path={v.path} element={<v.element></v.element>}>{ v.children && routerView(v.children) }</Route>
				})
			}
		</>
	)
}


const index = (props: Props) => {
	return (
		<BrowserRouter>
			<Routes>
				{
					routes.length > 0 && routerView(routes)
				}
			</Routes>
		</BrowserRouter>
	)
}

export default index